package com.example.javasystem.mapper;

import com.example.javasystem.entity.ETable;
import com.example.javasystem.entity.ITable;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface ITableMapper {
    @Insert("INSERT INTO internal_table " +
            "(timestamp, tank_number, temperature, ph_value, acetic_acid, alcohol, abnormal_num) " +
            "VALUES " +
            "(#{timestamp}, #{tankNumber}, #{temperature}, #{phValue}, #{aceticAcid}, #{alcohol}, #{abnormalNum})")
    void insert(ITable iTable);

    // 查找所有数据
    @Select("select * from internal_table")
    List<ITable> getAllData();

    // 查找指定罐体的数据
    @Select("select * from internal_table where tank_number = #{tankNumber}")
    List<ITable> selectByTankNumber(Integer tankNumber);

    // 按时间范围查询数据
    @Select("select * from internal_table where timestamp between #{startTime} and #{endTime}")
    List<ITable> selectByTimeRange(@Param("startTime") Date startTime, @Param("endTime") Date endTime);
}
